<template>
	<view class="box">
		
		<view>
			<view class="u-page">
				<view v-if="current==0" class="page1">
					<pro :type="type" :parm="parm" />
				</view>
				<view v-else-if="current==1" class="page2">
					<pro />
				</view>
				<view v-else class="page3">
					<order :parm="parm" />
				</view>
			</view>


		</view>
		<u-tabbar :before-switch="beforeSwitch" v-model="current" :list="list"></u-tabbar>
	</view>


</template>
<script>
	import order from "../workbench/index.vue"
	import pro from "./pro.vue";
	import foo from "../msg/footer.vue";
	export default {
		components: {
			foo,
			pro,
			order
		},
		data() {
			return {
				mobile: '',
				parm: '',
				current: 0,
				list: [{
						iconPath: "shopping-cart",
						selectedIconPath: "shopping-cart-fill",
						text: '购买产品',
						customIcon: false,
					},
					{
						iconPath: "phone",
						selectedIconPath: "phone-fill",
						text: '电话咨询',
						customIcon: false,
					},

					{
						iconPath: "file-text",
						selectedIconPath: "file-text-fill",
						text: '订单查询',
						customIcon: false,
					}
				],

				show: false,
				type: 2
			}

		},
		onLoad(e) {
			console.log(e, 4444);
			this.type = e.type
			this.parm = e.parm
			if (e.tab) {
				this.current = e.tab
			}


		},
		methods: {
			
			beforeSwitch(index) {
				if (index == 1) {

					uni.makePhoneCall({
						phoneNumber: '4008-567-560', // 电话号码
						success: function() {
					 	console.log('拨打电话成功');
						},
						fail: function() {
							console.log('拨打电话失败');
						}
					});
					return false
				} else {
					return true
				}

			},


		}
	}
</script>



